<?php

namespace App\Kuafu\Order\Model;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Kuafu\Base\Model\BaseModel;

class OrderOperateRecordModel extends BaseModel
{
    use HasFactory;

    public    $timestamps = false;
    protected $connection = 'mysql';
    protected $table      = 'order_operate_record';
    protected $fillable   = ['orderId', 'type', 'record', 'username', 'userId', 'userType', 'createdAt'];
    protected $hidden     = [];

    public const RECORD_TYPE_ORDER             = 1; // 下单
    public const RECORD_TYPE_ORDER_PAY         = 2; // 结账
    public const RECORD_TYPE_ORDER_PAY_REVERSE = 3; // 反结账

    public const RECORD_TYPES = [
        self::RECORD_TYPE_ORDER             => '下单',
        self::RECORD_TYPE_ORDER_PAY         => '结账',
        self::RECORD_TYPE_ORDER_PAY_REVERSE => '反结账',
    ];

    public const USER_TYPE_STAFF    = 0; // 后台运营
    public const USER_TYPE_CUSTOMER = 1; // 用户

    public function getRecordTypeTextAttribute(): string
    {
        return static::RECORD_TYPES[$this->type] ?? '';
    }
}
